/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.marcosperon.bean.hb;

import org.hibernate.cfg.Configuration;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.event.service.spi.EventListenerRegistry;
import org.hibernate.event.spi.EventType;
import org.hibernate.integrator.spi.Integrator;
import org.hibernate.metamodel.source.MetadataImplementor;
import org.hibernate.service.spi.SessionFactoryServiceRegistry;

/**
 *
 * @author Marcos Peron
 */
public class HbCustomIntegrator implements Integrator {

    //private HbSaveOrUpdateListener myListener = new HbSaveOrUpdateListener();
    
    /**
     * 
     * @param configuration
     * @param implementor
     * @param registry
     */
    @Override
    public void integrate(Configuration configuration, SessionFactoryImplementor implementor, SessionFactoryServiceRegistry registry) {
        final EventListenerRegistry eventRegistry = registry.getService(EventListenerRegistry.class);
    //    eventRegistry.prependListeners(EventType.PRE_UPDATE, myListener);
    //    eventRegistry.prependListeners(EventType.PRE_INSERT, myListener);
    }

    /**
     * 
     * @param sfi
     * @param sfsr
     */
    @Override
    public void disintegrate(SessionFactoryImplementor sfi, SessionFactoryServiceRegistry sfsr) {
    }

    /**
     * 
     * @param mi
     * @param sfi
     * @param sfsr
     */
    @Override
    public void integrate(MetadataImplementor mi, SessionFactoryImplementor sfi, SessionFactoryServiceRegistry sfsr) {
    }
}